<?php
include_once("../modules/checkA.php");
include_once("../../config.php");
$plate=select_one_line_all_items($table_Prefix."plate","mid = 'unit'");
?>


<?
//用来判断当前系统属于什么板块
$system_part = $plate['mid'];

if(!$_REQUEST ['applydate'])
{
    $_REQUEST ['applydate']=date("Y-m");
}
$applydate  = addslashes($_REQUEST ['applydate']);

//include_once("collect-function.php");
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
<head>
       <?php include ROOT_PATH_.'/controller/common/module/head.php'; ?>
    <?php include 'modules/head.php'; ?>



 
</head>

<body>

<div id="topbar">   <?php include ROOT_PATH_.'/controller/common/module/topbar.php'; ?></div>

<div id="container" class="<? echo $system_part ?>">

    <div id="maincontent">

        <div id="sidebar">
            <?php include ROOT_PATH_.'/controller/common/module/sidebar.php'; ?>
        </div>




        <div id="content">




            <h1>单位汇总</h1>



            <?
            $sum_money['table']           = 'athlon_case as c';
            $sum_money['where']           = "c.status = '完成'";
            $sum_money['left_table'][]    = "athlon_unit as d";
            $sum_money['left_table_on'][] = "c.unit = d.nid";
            $sum_money['items']           = "c.unit,d.name,d.sname";
            $sum_money['sum']             = 'c.sum';
            $sum_money['sum_as_name']     = 'sum_total';
            $sum_money['group']           = 'c.unit';
            $sum_money['sort']            = 'sum_total';
            $sum_money['by']              = 'desc';
            $sum_money['limit']           = 10;
            $rank_sum_list    = count_sum_group_sory_by($sum_money);
            ?>

            <?
            $profit['table']           = 'athlon_case as c';
            $profit['where']           = "c.status = '完成'";
            $profit['left_table'][]    = "athlon_unit as d";
            $profit['left_table_on'][] = "c.unit = d.nid";
            $profit['items']           = "c.unit,d.name,d.sname";
            $profit['sum']             = 'c.profit';
            $profit['sum_as_name']     = 'sum_total';
            $profit['group']           = 'c.unit';
            $profit['sort']            = 'sum_total';
            $profit['by']              = 'desc';
            $profit['limit']           = 10;
            $rank_profit_list    = count_sum_group_sory_by($profit);
            ?>

            <?

            $case_number['table']           = 'athlon_case as c';
            $case_number['where']           = "c.status = '完成'";
            $case_number['left_table'][]    = "athlon_unit as d";
            $case_number['left_table_on'][] = "c.unit = d.nid";
            $case_number['items']           = "c.unit,d.name,d.sname";
            $case_number['sum']             = 'c.profit';
            $case_number['sum_as_name']     = 'sum_total';

            $case_number['count']             = 'c.nid';
            $case_number['count_as_name']     = 'count_nid';


            $case_number['group']           = 'c.unit';
            $case_number['sort']            = 'count_nid';
            $case_number['by']              = 'desc';
            $case_number['limit']           = 10;
            $rank_number_list    = count_sum_group_sory_by($case_number);

            ?>





            <hr/>


            <!-- 用$system_part .list_boxes来控制来到确认板块信息显示-->
            <div class="list-box">


<style>
    .table-line{float: left; width: 460px; margin-right:25px;}
</style>
<div class="table-line">
                <h2>项目金额排行</h2>
                
                <table class="layui-table">
                    <colgroup>
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >

                    </colgroup>
                    <thead>
                    <tr>

                        <th>排名</th>
                        <th>单位</th>
                        <th>总额</th>
                    </tr>
                    </thead>
                    <tbody>
<? foreach ($rank_sum_list as $k =>$v ){?>
                    <tr >
                        <td><?echo $k+1?></td>
                        <td><?echo $v['name']?></td>
                        <td><?echo $v['sum_total']?></td>
                    </tr>
<?}?>
                    </tbody>
                </table>
</div>



<div class="table-line">
                <h2>项目利润排行</h2>
                <table class="layui-table">
                    <colgroup>
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >
                        <col >

                    </colgroup>
                    <thead>
                    <tr>
                        <th>排名</th>
                        <th>单位</th>
                        <th>利润</th>
                    </tr>
                    </thead>
                    <tbody>
                    <? foreach ($rank_profit_list as $k =>$v ){?>
                        <tr >
                            <td><?echo $k+1?></td>
                            <td><?echo $v['name']?></td>
                            <td><?echo $v['sum_total']?></td>
                        </tr>
                    <?}?>
                    </tbody>
                </table>
</div>




                <div class="table-line">
                    <h2>项目数量排行</h2>

                    <table class="layui-table">
                        <colgroup>
                            <col >
                            <col >
                            <col >
                            <col >
                            <col >
                            <col >
                            <col >
                            <col >
                            <col >
                            <col >
                            <col >
                        </colgroup>
                        <thead>
                        <tr>
                            <th>排名</th>
                            <th>单位</th>
                            <th>数目</th>
                            <th>平均利润</th>
                        </tr>
                        </thead>
                        <tbody>
                        <? foreach ($rank_number_list as $k =>$v ){?>
                            <tr >
                                <td><?echo $k+1?></td>
                                <td><?echo $v['name']?></td>
                                <td><?echo $v['count_nid']?></td>
                                <td><?echo round($v['sum_total']/$v['count_nid'])?></td>
                            </tr>
                        <?}?>
                        </tbody>
                    </table>
                </div>









                                        <table class="layui-table">
                                            <colgroup> 
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
    
                                            </colgroup>
                                            <thead>
                                            <tr>
				
                                                <th>互相仇恨</th>
                                                <th>仇视我方</th>
                                                <th>我方仇视</th>
                                                <th>我方不满</th>
                                                <th>不满我方</th>
                                                <th>普通</th>
                                                <th>黑名单</th>
                                                <th>无</th>
                                             </tr>
                                            </thead>
                                            <tbody>



 

                                            <tr >
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                   
 
                                            </tr>
  

                        </tbody>
                    </table>

 

 
 <h2>关系统计</h2>


                                        <table class="layui-table">
                                            <colgroup> 
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
                                                <col >
    
                                            </colgroup>
                                            <thead>
                                            <tr>
				
                                                <th>客户</th>
                                                <th>目标客户</th>
                                                <th>同行</th>
                                                <th>供应商</th>
                                                <th>竞争对手</th>
                                                <th>无</th>
                                          
                                             </tr>
                                            </thead>
                                            <tbody>



 

                                            <tr >
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                   
 
                                            </tr>
  

                        </tbody>
                    </table>

 



















</div>


                <!--list-box end-->
            </div>

            <!--content端點01-->
        </div>
        <!--maincontent端點01-->
        <br class="clearfloat"/>
    </div>
    <!--container端點01-->
</div>









<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?> </body>
</html>
